#include <cstdio>
#include <iostream>

using namespace std; 

char p2c[256], c2p[256]; 

int main()
{
	string plain, cipher, c_text; 

	//freopen("p1071_2.in", "r", stdin); 
	
	getline(cin, cipher);
	getline(cin, plain); 
	getline(cin, c_text); 
	
	for (unsigned i=0; i<plain.size(); i++) {
		if (p2c[(int)plain[i]]==0) {
			p2c[(int)plain[i]] = cipher[i]; 
		} else {
			if (p2c[(int)plain[i]]!=cipher[i]) {
				cout<<"Failed\n"; 
				return 0; 
			}
		}
		if (c2p[(int)cipher[i]]==0) {
			c2p[(int)cipher[i]] = plain[i]; 
		} else {
			if (c2p[(int)cipher[i]]!=plain[i]) {
				//cout<<"i="<<i<<", cipher[i]="<<cipher[i]<<"/"<<(int)cipher[i]<<", plain="<<plain[i]<<"/"<<(int)plain[i]<<endl; 
				cout<<"Failed\n"; 
				return 0; 
			}
		}
	}

	for (char i='A'; i<='Z'; i++) {
		if (p2c[(int)i]==0) {
			//printf("i=%d, p2c[i]=%c/%d\n", i, p2c[(int)i], p2c[(int)i]); 
			cout<<"Failed\n"; 
			return 0; 
		}
	}
	
	for (unsigned i=0; i<c_text.size(); i++) {
		if (c2p[(int)c_text[i]]==0) {
			//cout<<"i="<<i<<", c_text[i]="<<c_text[i]<<"/"<<(int)c_text[i]<<endl; 
			cout<<"Failed\n"; 
			return 0; 
		}
	}
	
	for (unsigned i=0; i<c_text.size(); i++) {
		cout<<c2p[(int)c_text[i]]; 
	}
	cout<<"\n";  

	return 0; 
}


